layui.define([ 'form', 'laydate', 'table' ], function(exports) {
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var rentingTable = null;
    var view ={
        init:function(){
            this.initTable();
            this.initSearchForm();
            this.initToolBar();
            window.dataReload = function(){
                Lib.doSearchForm($("#searchForm"),rentingTable)
            }
        },
        initTable:function(){
            rentingTable = table.render({
                elem : '#rentingTable',
                height : Lib.getTableHeight(1),
                cellMinWidth: 100,
                method : 'post',
                url : Common.ctxPath + '/cms/renting/firstcheckList.json' // 数据接口
                ,page : Lib.tablePage // 开启分页
                ,limit : 10,
                cols : [ [ // 表头
                    {
                        type : 'checkbox',
                        fixed:'left',
                    },
                    {

                        field : 'name',
                        title : '姓名',
                        align: 'center',
                        width:"165"
                    },
                    {

                        field : 'year',
                        title : '年度',
                        align: 'center',
                        width:"90"
                    },
                    {

                        field : 'declarationGradeText',
                        title : '申报档次',
                        align: 'center',
                        width:"90"
                    },
                    {

                        field : 'numberDeclarations',
                        title : '申报月数',
                        align: 'center',
                        width:"90"
                    },
                    {

                        field : 'totalAmount',
                        title : '合计金额',
                        align: 'right',
                        width:"135",templet:function (d) {
                        return Common.getMoney(d.totalAmount);
                    }
                    },
                    {

                        field : 'businessState',
                        title : '业务状态',
                        align: 'center',
                        width:"135"
                    },
                    {

                        field : 'processResult',
                        title : '审核结果',
                        align: 'center',
                        width:"135"
                    },
                    {

                        field : 'dateReporting',
                        title : '上报日期',
                        align: 'center',
                        width:"180"
                    }
                ] ]

            });

            table.on('checkbox(rentingTable)', function(obj){
                var industrialTalents = obj.data;
                if(obj.checked){
                    //按钮逻辑Lib.buttonEnable()
                }else{

                }
            })
        },

        initSearchForm:function(){
            Lib.initSearchForm( $("#searchForm"),rentingTable,form);
        },
        initToolBar:function(){
            toolbar = {
                find : function() { // 获取选中数目
                    var data = Common.getOneFromTable(table,"rentingTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/cms/renting/findenterprise.do?id="+data.id;
                    Common.openDlg(url,"租房补贴>查看");
                },
                process : function() { // 获取选中数目
                    var businessType = Common.businessType.renting;
                    var data = Common.getOneFromTable(table,"rentingTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/cms/businessProcess/index.do?businessType="+businessType+"&businessId="+data.id;
                    Common.openDlg(url,"流程信息>编辑");
                },
            };
            $('.ext-toolbar').on('click', function() {
                var type = $(this).data('type');
                toolbar[type] ? toolbar[type].call(this) : '';
            });
        }
    }
    exports('business',view);

});